package com.wyl.pmd.rule.errorprone;

import java.util.ArrayList;
import java.util.Collection;

public class ClassCastExceptionWithToArray {

	public static void main(String[] args) {

		Collection c = new ArrayList();
		Integer obj = new Integer(1);
		c.add(obj);

		// bad,会抛出ClassCastException异常
		Integer[] a = (Integer[]) c.toArray();

		// good
		Integer[] b = (Integer[]) c.toArray(new Integer[c.size()]);

	}

}
